﻿using Architecture.Domian.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Architecture.Repository
{
    /// <summary>
    /// 泛型接口
    /// </summary>
    /// <typeparam name="T">数据实体</typeparam>
    /// 泛型：泛型类 泛型接口 泛型方法
    /// new() 表示此类可被实例化
    /// struct 值类型：int float double bool enum...
    /// class  引用类型：class string interface datetime 委托

    public interface IRepository<T> where T : class, new()
    {
        Task<int> AddAsync(T entity);
        Task<int> UpdateAsync(T entity);
        Task<T> GetByIdAsync(int id);
        Task<T> GetByFuncAsync(Expression<Func<T,bool>> expre);
        Task<List<T>> GetAllAsync();
        // 多条件组合查询
        Task<List<T>> GetAsync(Expression<Func<T, bool>> expre);
        Task<int> DeleteAsync(T entity);
        Task<int> BatchDeleteAsync(List<T> roleInfos);

    }
}
